package com.houger.ddd.redpacket.application;

import com.houger.ddd.redpacket.facade.dto.GrabRedPacketDto;
import com.houger.ddd.redpacket.domain.GrabRedPacketDomain;
import com.houger.ddd.redpacket.infra.entity.GrabRedPacket;

/**
 * @author Houger.
 * @date 2024年04月21日 17:57.
 */
public class GrabRedPacketAdaptor {
    public static GrabRedPacket toEntity(GrabRedPacketDomain domain){
        final GrabRedPacket grabRedPacket = new GrabRedPacket();
        grabRedPacket.setRedPacketId(domain.getRedPacketId());
        grabRedPacket.setUserId(domain.getUserId());
        grabRedPacket.setMoney(domain.getMoney());
        grabRedPacket.setGrabTime(domain.getGrabTime());
        grabRedPacket.setBestLuck(domain.getBestLuck());
        return grabRedPacket;
    }

    public static GrabRedPacketDomain toDomain(final GrabRedPacketDto dto) {
        return GrabRedPacketDomain.builder()
            .redPacketId(dto.getRedPacketId())
            .grabTime(dto.getGrabTime())
            .money(dto.getMoney())
            .userId(dto.getUserId())
            .bestLuck(dto.getBestLuck())
            .build();
    }
}
